package cn.edu.qfnu.oj.service.impl;

import cn.edu.qfnu.common.exception.db.NoRecordFoundException;
import cn.edu.qfnu.common.exception.db.WrongParameterException;
import cn.edu.qfnu.common.service.Impl.BaseServiceImpl;
import cn.edu.qfnu.oj.dao.LevelDao;
import cn.edu.qfnu.oj.dao.StudentDao;
import cn.edu.qfnu.oj.entity.Student;
import cn.edu.qfnu.oj.service.StudentService;
import org.hibernate.SessionFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

@Service("studentService")
public class StudentServiceImpl extends BaseServiceImpl<Student, String> implements StudentService{

    private StudentDao studentDao;
    private LevelDao levelDao;
    private SessionFactory sessionFactory;

    @Autowired
    public StudentServiceImpl(StudentDao studentDao, LevelDao levelDao, SessionFactory sessionFactory) {
        this.studentDao = studentDao;
        this.levelDao = levelDao;
        this.sessionFactory = sessionFactory;
    }

    @Override
    public boolean isExist(String studentId, String email)
            throws NoRecordFoundException {
        return studentDao.isExist(studentId, email);
    }

    @Override
    public Student checkPassword(String studentId, String password) throws WrongParameterException {
        return studentDao.checkPassword(studentId, password);
    }

}
